package com.chenhy.springbootvuesmbms.service;

import com.chenhy.springbootvuesmbms.mapper.CustomerMapper;
import com.chenhy.springbootvuesmbms.pojo.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public List<Customer> queryAllCustomer() {
        return customerMapper.queryAllCustomer();
    }

    @Override
    public Customer queryCustomerById(int id) {
        return customerMapper.queryCustomerById(id);
    }

    @Override
    public List<Customer> fuzzyBillQuery(String condition) {
        return customerMapper.fuzzyBillQuery(condition);
    }

    @Override
    public int addCustomer(Customer customer) {
//        LoginUser loginUser = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        customer.setCreatedBy(loginUser.getId());
//        customer.setModifyBy(loginUser.getId());
//        return customerMapper.addCustomer(customer);
        return 0;
    }

    @Override
    public int updateCustomer(Customer customer) {
//        LoginUser loginUser = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        customer.setModifyBy(loginUser.getId());
//        return customerMapper.updateCustomer(customer);
        return 0;
    }

    @Override
    public int deleteCustomer(int id) {
        return customerMapper.deleteCustomer(id);
    }
}
